package com.nowcoder.community.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.nowcoder.community.entity.DiscussPost;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DiscussPostMapper extends BaseMapper<DiscussPost> {
    List<DiscussPost> findPageByUserId(int userId, int offset, int limit);

    List<DiscussPost> selectTest(int userId);

    @Update("UPDATE discuss_post SET comment_count = #{count} WHERE id = #{postId}")
    void updateCommentCountById(int postId, int count);

    @Update("UPDATE discuss_post SET comment_count = comment_count + #{count} WHERE id = #{postId}")
    void addCommentCountById(int postId, int count);
}
